// #ifndef KVSTORE2PCSYSTEM_H_INCLUDE
// #define KVSTORE2PCSYSTEM_H_INCLUDE
#pragma once

#include <cstring>
#include <iostream>
#include <string>
#include <vector>
#include "core.hpp"
using namespace std;

struct Info {
    string ip;
    int port;
};
struct Command {
    string Command_name, value1, value2;
    vector<string> values;
    Command() {
        Command_name = "";
        value1 = "";
        value2 = "";
    }
};
/*
kvstore2pcsystem 服务器结点

mode ：结点mode，0 coordinator，1 participant, 2 raft
conf ：配置文件的名字(包含路径)

method：
1. get
2. init
3. 构造函数
4. 析构函数

*/
class kvstore2pcsystem {
private:
    Mode mode = MODE_INVALID;
    char* conf;
    std::vector<NodeInfo>   pinfo;
    NodeInfo                cinfo;
    std::vector<NodeInfo>   finfo;
    void init();
public:
    char* getConf() {return conf;}
    int getMode() {return mode;}
    std::vector<NodeInfo> getPinfo() {return pinfo;}
    NodeInfo getCinfo() {return cinfo;}
    std::vector<NodeInfo> getFinfo() {return finfo;}
    bool readConf_2PC(std::vector<NodeInfo> & p, NodeInfo & c);
    bool readConf_RAFT(std::vector<NodeInfo> & p, NodeInfo & c, std::vector<NodeInfo> & f);
    void showInfo(std::vector<NodeInfo>  p, NodeInfo  c, std::vector<NodeInfo> & f);
    kvstore2pcsystem(int argc, char* argv[]);
    ~kvstore2pcsystem();
};


// #endif